package cn.wolfcode.luowowo.website.controller;

import cn.wolfcode.louwowo.cache.service.IUserInfoRedisService;
import cn.wolfcode.luowowo.article.query.TravelQuery;
import cn.wolfcode.luowowo.article.service.IStrategyDetailService;
import cn.wolfcode.luowowo.article.service.ITravelCommendService;
import cn.wolfcode.luowowo.article.service.ITravelService;
import cn.wolfcode.luowowo.member.domain.UserInfo;
import cn.wolfcode.luowowo.website.annotation.UserParam;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpSession;

@Controller
public class IndexController {
    @Reference
    private IUserInfoRedisService redisService;
    @Reference
    private ITravelCommendService travelCommendService;
    @Reference
    private ITravelService travelService;
    @Reference
    private IStrategyDetailService strategyDetailService;

    @RequestMapping("")
    public String index(Model model,HttpSession session, @UserParam UserInfo userInfo) {
        //把用户登陆对象共享到session中
        session.setAttribute("userInfo", userInfo);
        model.addAttribute("tcs",travelCommendService.getTop5());
        model.addAttribute("sc",strategyDetailService.getStrategyDetailsByIsAbroadTop10(true).get(0));
        return "index/index";
    }

    @RequestMapping("index/travelPage")
    private String travelPage(Model model, TravelQuery qo){
        model.addAttribute("pageInfo",travelService.query(qo));
        return "index/travelPageTpl";
    }
}
